""" 
    twExtJS - ToscaWidgets wrapper for ExtJS (see http://extjs.com)
    
    Distributed under the terms of Lesser GNU Public License.
    
    (c) 2007 - Ricardo Girardi Sixel 
"""

import pylons 

def dejsonify(func, *args, **kwargs):
    pylons.response.headers['Content-Type'] = 'text/javascript'
    data = func(*args, **kwargs)
    if isinstance(data, list):
        msg = "JSON responses with Array envelopes are susceptible to " \
              "cross-site data leak attacks, see " \
              "http://pylonshq.com/warnings/JSONArray"
        warnings.warn(msg, Warning, 2)
        log.warning(msg)
    log.debug("Returning JSON wrapped action output")
    return simplejson.dumps(data)
jsonify = decorator(jsonify)